package com.example.service;

import com.example.repository.UserRepository;

import com.example.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    private final UserRepository userRepository;

    @Autowired
    public UserService(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    public User getUserById(String id) {
        return userRepository.getUserById(id);
    }

    public void addUser(User user) {
        userRepository.insertUser(user);
    }

    public void deleteUser(String id) {
        userRepository.deleteUserById(id);
    }

    public void updateUser(User user) {
        userRepository.updateUser(user);
    }

    public List<User> getAllUsers() {
        return userRepository.getAllUsers();
    }
}